package ynu.edu.dao;

//import org.springframework.data.jpa.repository.Modifying;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import ynu.edu.po.Student;

import java.util.List;

@Repository
public interface IStudentDao extends CrudRepository<Student, Long> {

    List<Student> findStudentsByAgeBetweenAndSexIsAndStuNameContaining(Integer min, Integer max, Boolean sex, String name);

    Student findStudentByStuIdAndPassword(Long id, String password);

    @Query("select s from Student s where (s.age between :min and :max) and s.sex =:sex ")
    List<Student> queryFitStuList(@Param("max") Integer maxValue, @Param("min") Integer minValue, @Param("sex") Boolean sex);

    @Query("select s from Student s where (s.age between ?1 and ?2) and s.sex =?3 ")
    List<Student> queryFitStuList2(Integer min, Integer max, Boolean sex);
}
